home *** CD-ROM | disk | FTP | other *** search
- /*
- This file contains generic code seg entry points for use by 68K XFuns.
- For convienience, all setting and restoring of A4 is handled here.
-
- All the real work is done elsewhere by the routines:
-
- initialize()
- doevent(theEvent)
- dopredef()
- dofuncall(retval)
-
- This example uses all 4 possible entry points.
- The main() and funcall() entries are required for all XFuns.
- The predef() is used only if your XFun needs to reset something each time
- the doc is reevaluated. If it isn't used just pass a NULL to AddXfun().
- The handler() is used if your XFun needs access to events. If your XFun
- creates a window it must install a valid handler. If no handler is needed
- then don't call InstallEventHandler().
- */
-
- #include "A4globs.h" /* magic A4 macros */
- #include "callbackg.h" /* use "global" version of callbacks */
- #include "XFundef.h" /* prototypes for routines specific to this XFun */
-
- funptr callback; /* global used by all callback routines (callbackg.c) */
-
- static short handler(EventRecord *theEvent,funptr callbackptr)
- {
- int done;
- SetUpA4();
- done = doevent(theEvent);
- RestoreA4();
- return(done);
- }
-
- static short predef(funptr callbackptr)
- {
- SetUpA4();
- dopredef();
- RestoreA4();
- return(0);
- }
-
- static short funcall(double *retval,funptr callbackptr)
- {
- int ok;
- SetUpA4();
- ok = dofuncall(retval);
- RestoreA4();
- return(ok);
- }
-
- void main(funptr callbackptr)
- {
- EnterResource();
- callback = callbackptr; /* save callback in global for callbackg routines */
- AddXfun(FUNNAME,FUNPARMS,&funcall,&predef);
- InstallEventHandler(&handler);
- initialize();
- RestoreA4();
- }
-